﻿
Partial Class AttachmentListPopup
    Inherits System.Web.UI.Page
    Public Function GetIcons(ByVal type As String) As String
        Dim iconlocation As String
        Select Case type
            Case ".jpg", ".png", "bmp", "gif" : iconlocation = "Img.gif"
            Case ".doc", ".docx" : iconlocation = "word.png"
            Case ".pdf" : iconlocation = "pdf.png"
            Case ".xls", ".xlsx" : iconlocation = "excel.png"
            Case ".ppt", ".pptx" : iconlocation = "ppt.png"
            Case ".avi", ".mp4", ".mkv", ".wmv" : iconlocation = "video.png"
            Case ".ogg", ".mp3", ".wma" : iconlocation = "audio.png"
            Case ".zip", ".rar" : iconlocation = "zip.png"
            Case ".html", ".htm", ".php", ".aspx", ".vb", ".cs", ".js" : iconlocation = "web.png"
        End Select
        Return iconlocation
    End Function
    Protected Sub DeleteDocument_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim ConfirmResult As Boolean = ConfirmBox.Value
        If ConfirmResult = False Then
            Exit Sub
        End If

        Dim Row As System.Web.UI.WebControls.GridViewRow
        Row = sender.Parent.Parent
        Dim IDX As Label = Row.Cells(3).FindControl("ProjectDocumentID")
 
        Dim adapter As New AttachmentTableAdapters.AttachmentsTableAdapter
        Dim adapter2 As New AttachmentTableAdapters.BudgetDetailsTableAdapter

        adapter.DeleteAttachment(Val(IDX.Text))
        Dim currentAmount As Decimal = adapter.GetAttAmount(Val(IDX.Text))
        adapter2.UpdateAttAmount(currentAmount, Val(IDX.Text))
        Dim data As New Attachment.AttachmentsDataTable
        data = adapter.GetDataByRefID(Val(Request("BDID")))
        GridView1.DataSource = data
        GridView1.DataBind()

    End Sub
    Public Function GenerateOnClick(ByVal data As String) As String
        Return "window.open('Uploaded/" & data & "','view_document','menubar=0,resizable=1,width=800,height=600');"
    End Function


    Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
        Dim adapter As New AttachmentTableAdapters.AttachmentsTableAdapter
        Dim data As New Attachment.AttachmentsDataTable
        data = adapter.GetDataByRefID(Val(Request("BDID")))
        GridView1.DataSource = data
        GridView1.DataBind()

    End Sub
End Class
